/*
 * Copyright 2023 devaper
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.github.devaper.pigeon.annotation

typealias Attributes = HashMap<String, Any>

/**
 * 负责解析并展开所有的注解, 并自动处理 [AliasFor]
 */
interface AnnotationMetadata {

    /**
     * 是否包含指定的注解
     *
     * @param annotationJClass 注解的Class类型
     * @return Boolean
     */
    operator fun contains(annotationJClass: Class<*>): Boolean

    /**
     * 获取指定注解的所有属性
     *
     * @param annotationJClass 注解的Class类型
     * @return Attributes map
     */
    operator fun get(annotationJClass: Class<*>): Attributes?


    companion object {
        /**
         * 解析一组注解并创建出 [AnnotationMetadata]
         *
         * 由于提供了注解实例, 那么这里使用的是 [ReflectAnnotationMetadata]
         */
        @JvmStatic
        fun introspect(annotations: Array<Annotation>): AnnotationMetadata {
            return ReflectAnnotationMetadata(annotations)
        }
    }
}